<template>
  
  <view class="content">
    <image class="logo" src="/static/logo.png" />
    <view class="text-area">
      <text class="title">{{ title }} </text>
    </view>
    <van-button type="primary" @touchstart="postMessage">发送消息</van-button>
    <van-button class="btn" data-action="navigateBack" @touchstart="goBack"
      >navigateBack</van-button
    >
  </view>
</template>

<script setup lang="ts">
import { getUserInfo } from '@/api/index'
import { ref } from 'vue'
import { showNotify } from 'vant'

const title = ref('Hello')

const postMessage = () => {
  getUserInfo().then((res) => {
    console.log(res)
  })

  console.log(webview)

  // const mini = window.jWeixin.miniProgram
  // console.log(mini)
  // uni.getEnv(function (res) {
  //   console.log('当前环境：' + JSON.stringify(res))
  // })
  webview.postMessage({
    data: {
      action: 'message'
    }
  })
}

const goBack = () => {
  showNotify('123')
  // const mini = window.jWeixin.miniProgram
  webview.navigateBack()
}
</script>

<style type="sass" scoped>
.box {
  font-size: 15px;
}
</style>
